home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Family Forum 259
/
SOMC Family Forum 259 - Disc 1.iso
/
Xtras
/
Animation Wizard.dir
/
00013_Script_ScoreMgr
< prev
next >
Wrap
Text File
|
1997-05-10
|
16KB
|
478 lines
-- ScoreMgr script
property iUsersScoreSelection
property iGeneratedScoreSelection
property ichStart
property ichEnd
property iFrameStart
property iFrameEnd
property iStageWidth
property iStageHeight
property iStageRight
property iStageBottom
property iChannelAvailList
property ichReselect
property iLocReselect
property ikChStart
property ikChEnd
property ikFrameStart
property ikFrameEnd
property iLastFrame
property iNeedClean
on birth me
tell the stage
set iStageRight = the StageRight
set iStageBottom = the StageBottom
set iStageWidth = iStageRight - the StageLeft
set iStageHeight = iStageBottom - the StageTop
end tell
set ikChStart = 1
set ikChEnd = 2
set ikFrameStart = 3
set ikFrameEnd = 4
set iChannelAvailList = []
set iGeneratedScoreSelection = []
set ichReselect = 18
return me
end birth
on mGetStageWidth me
return iStageWidth
end mGetStageWidth
on mGetStageHeight me
return iStageHeight
end mGetStageHeight
on mGetStageRight me
return iStageRight
end mGetStageRight
on mGetStageBottom me
return iStageBottom
end mGetStageBottom
on mInit me, nFramesNeeded, nChannelsNeeded
global gDevelopmentFlag
if nFramesNeeded > 32000 then
alert("The combination of text and settings you have chosen would generate an " & ¼
"animation of more than 32000 frames. Please simplify your selections and try again.")
return FALSE
end if
tell the stage
set iUsersScoreSelection = the scoreSelection
set iLastFrame = the lastFrame
set iStageRight = the StageRight --check the stage location again, in case it has changed.
set iStageBottom = the StageBottom
set iStageWidth = iStageRight - the StageLeft
set iStageHeight = iStageBottom - the StageTop
end tell
if iUsersScoreSelection = [] then
alert("Please select a range of cells or frames in the score and try again.")
return FALSE
end if
if gDevelopmentFlag then -- for development only
mForceSelection(me)
end if
set iLocReselect = the loc of sprite ichReselect -- save for later
puppetSprite ichReselect, TRUE
-- We must parse the user's selection and do the appropriate thing.
set firstScoreSelectionList = getAt(iUsersScoreSelection, 1)
set ichStart = getAt(firstScoreSelectionList, ikChStart)
set ichEnd = getAt(firstScoreSelectionList, ikChEnd)
set iFrameStart = getAt(firstScoreSelectionList, ikFrameStart)
set iFrameEnd = getAt(firstScoreSelectionList, ikFrameEnd)
set theGeneratedFrameEnd = iFrameStart + nFramesNeeded - 1
--check to see if the ending frame is the last frame and put in a tempo setting if it is.
set theEnd to max(theGeneratedFrameEnd, iFrameEnd)
if theEnd >= iLastFrame then
set iNeedClean = true
tell the stage
beginRecording
go to frame (theEnd + 5)
set the frameTempo to 5
endrecording
end tell
else
set iNeedClean = false
end if
set iChannelAvailList = []
if (ichStart = -5) and (ichEnd = 48) then -- user selected a whole frame
-- Make a list saying all 48 channels are available
repeat with ch = 1 to 48
add iChannelAvailList, ch
end repeat
tell the stage
beginRecording
-- If the user selected a range of full frames, delete these frames.
-- This will simulate an insertion cursor
if iFrameEnd >= iFrameStart then
go to frame iFrameStart
repeat with theFrameNum = iFrameStart to iFrameEnd
-- The following line deletes any frame marker
set the frameLabel = 0
deleteFrame
end repeat
end if
-- Now we basically have an insertion cursor in the score
-- So, here we insert frames
tell the stage
if iFrameStart = 1 then
go to frame 1
else
go to frame iFrameStart - 1
end if
repeat with i = 1 to nFramesNeeded
insertFrame
end repeat
if iFrameStart = 1 then
go to frame 1
else
go to frame iFrameStart - 1
end if
end tell
--check again, in case the ending frame got deleted while deleting & inserting frames.
set theEnd to max(theGeneratedFrameEnd, iFrameEnd)
if theEnd >= iLastFrame then
set iNeedClean = true
go to frame (theEnd + 5)
set the frameTempo to 5
else
set iNeedClean = false
end if
endRecording
end tell
set iGeneratedScoreSelection = [[-5, 48, iFrameStart, theGeneratedFrameEnd]]
-- Otherwise, the user has selected one or more channels
else
-- Build a list of channels that the user has selected.
set iGeneratedScoreSelection = []
set nItems = count(iUsersScoreSelection)
repeat with thisSelection = 1 to nItems
set thisScoreSelectionList = getAt(iUsersScoreSelection, thisSelection)
set thisChStart = getAt(thisScoreSelectionList, ikChStart)
if thisChStart <= 0 then
alert("Please make your score selection in channels 1 through 48")
mClean me
return FALSE
end if
set thisChEnd = getAt(thisScoreSelectionList, ikChEnd)
-- add this to the Generated score selection
set thisScoreSelection = [thisChStart, thisChEnd, iFrameStart, theGeneratedFrameEnd]
addAt(iGeneratedScoreSelection, thisScoreSelection)
-- add each of the user's selected channels to the channel available list
repeat with thisCh = thisChStart to thisChEnd
add(iChannelAvailList, thisCh)
end repeat
end repeat
set nChannelsAvail = count(iChannelAvailList)
if nChannelsNeeded > nChannelsAvail then
alert("Your animation requires" && nChannelsNeeded && "channels, " & ¼
"but you have only selected" && nChannelsAvail && "channels. " & ¼
"Please select more and try again.")
mClean me
return FALSE
end if
-- If we don't have enough frames in the selection,
-- duplicate the last frame until we have enough
--but make sure we don't duplicate the tempo channel
set nFramesSelected = iFrameEnd - iFrameStart + 1
if nFramesSelected < nFramesNeeded then
set nFramesToAdd = nFramesNeeded - nFramesSelected
tell the stage
go to frame iFrameEnd
beginRecording
repeat with i = 1 to nFramesToAdd
duplicateFrame
set the frameTempo = 0
end repeat
endRecording
go to frame iFrameStart
end tell
end if --nFramesSelected
end if
-- Finally, clear out all user selected cells in the generated score
-- and clear out the tempo channel, in case of reselection
tell the stage
beginRecording
go to frame iFrameStart
repeat with thisFrame = iFrameStart to iFrameEnd
repeat with chIndex = 1 to nChannelsAvail
set thisCh = getAt(iChannelAvailList, chIndex)
if the castNum of sprite thisCh <> 0 then
set the type of sprite thisCh = 0 -- delete anything that's there
end if
end repeat
set the frameTempo = 0
updateFrame
end repeat
endRecording
end tell
--put "Channels that are available are :" && iChannelAvailList
--put "The Generated score selection is:" && iGeneratedScoreSelection
updateStage
return TRUE
end mInit
on mShowReselect me
set the scoreSelection = iUsersScoreSelection
set the loc of sprite ichReselect = iLocReselect
set the castNum of sprite ichReselect = the number of cast "ReselectButton"
updateStage
end mShowReselect
on mForceSelection me
-- This ensures that we don't overwrite stuff in the MIAW
-- when we are using it as a development movie (not a MIAW)
-- If I goofed and forgot to select a testing area of the score,
-- make believe I selected frames 101 to 125
set nItems = count(iUsersScoreSelection)
repeat with thisSelectionNum = 1 to nItems
set thisScoreSelectionList = getAt(iUsersScoreSelection, thisSelectionNum)
set thisStart = getAt(thisScoreSelectionList, ikFrameStart)
set thisEnd = getAt(thisScoreSelectionList, ikFrameEnd)
if (thisStart < 101) or (thisEnd < 101) then
setAt(thisScoreSelectionList, ikFrameStart, 101)
setAt(thisScoreSelectionList, ikFrameEnd, 125)
setAt(iUsersScoreSelection, thisSelectionNum, thisScoreSelectionList)
end if
end repeat
end mForceSelection
on mReselect me
if iGeneratedScoreSelection = [] then
alert("Internal error, mReselect - there is nothing to reselect.")
return
end if
tell the stage
set the scoreSelection = iGeneratedScoreSelection
end tell
end mReselect
on mGetGeneratedScoreSelection me
return iGeneratedScoreSelection
end mGetGeneratedScoreSelection
on mGetStartFrame me
return iFrameStart
end mGetStartFrame
on mGetNextSelectedChannel me
-- Get the first in the list of users selected channels set up in mInit,
-- return it, and eliminate it from the list of available channels
if iChannelAvailList = [] then
alert("Internal error, mGetNextSelectedChannel is out of available channels")
return -99
end if
set theCh = getAt(iChannelAvailList, 1)
deleteAt(iChannelAvailList, 1)
return theCh
end mGetNextSelectedChannel
on mWriteSprite me, f, ch, cm, theForeColor, theBackColor, x, y, w, h
global gkTransparentInk
tell the stage
go frame ( f )
beginRecording
-- sprite properties
set the castNum of sprite ch = cm
set the foreColor of sprite ch = theForeColor
set the backColor of sprite ch = theBackColor
set the locH of sprite ch = x
set the locV of sprite ch = y
set the ink of sprite ch = gkTransparentInk
set the tweened of sprite ch to 1
-- last two are primarily to support Zoom effect
if w <> 0 then
set the width of sprite ch = w
end if
if h <> 0 then
set the height of sprite ch = h
end if
updateFrame
-- debug( "Writing Sprite:" && s && the type of sprite s && the castNum of sprite s && ¼
the foreColor of sprite s && the backColor of sprite s && ¼
the locH of sprite s && the locV of sprite s && ¼
the width of sprite s && the height of sprite s )
endRecording
end tell
end mWriteScore
on mWriteFrameControl me, theFrame, theControl, theValue
if theControl = #Transition then -- copy a known transition
copyToClipBoard member (the number of member theValue)
-- Create a cast member in the stage movie
set castNumTransTarget = mFindFreeCastRun(goCastMgr, 1, 1)
end if
tell the stage
go frame theFrame
beginRecording
case theControl of
#Label: set the frameLabel = theValue
#Tempo: set the frameTempo = theValue
#Transition: -- Copied transition to clipboard already (above)
pasteClipboardInto member castNumTransTarget
set the name of member castNumTransTarget = "Transition" && string(the ticks)
set the frameTransition = castNumTransTarget
#Sound1: set the frameSound1 = theValue
#Sound2: set the frameSound2 = theValue
otherwise alert("Bad control value passed to mWriteFrameControl" & theControl)
end case
updateFrame
endRecording
end tell
end mWriteFrameControl
on mWriteFrameLabel me, theFrame, theLabel
mWriteFrameControl(me, theFrame, #Label, theLabel)
end mWriteFrameLabel
-- Writing a frame delay is painful. Unfortunately, there is no
-- easy way to just set this property. So, we have to write 1
-- frame for each second delay, and set the frame tempo
-- of that frame to 1 frame per second.
--on mWriteFrameDelay me, theFrame, nSeconds
-- if nSeconds > 0 then
-- repeat with thisFrame = 1 to nSeconds
-- mWriteFrameControl(me, (theFrame + thisFrame - 1), #Tempo, 1)
-- end repeat
-- end if
--end mWriteFrameDelay
--undocumented lingo: setting the frameTempo to a negative number sets it to wait for that many seconds.
on mWriteFrameDelay me, theFrame, nSeconds
mWriteFrameControl(me,theFrame, #Tempo, -nSeconds )
end mWriteFrameDelay
on mWriteFrameTempo me, theFrame, theTempo
mWriteFrameControl(me, theFrame, #Tempo, theTempo)
end mWriteFrameTempo
on mWriteFrameTransition me, theFrame, theTransition
mWriteFrameControl(me, theFrame, #Transition, theTransition)
end mWriteFrameTransition
on mWriteFrameSound1 me, theFrame, theSound1
mWriteFrameControl(me, theFrame, #Sound1, theSound1)
end mWriteFrameSound1
on mWriteFrameSound2 me, theFrame, theSound2
mWriteFrameControl(me, theFrame, #Sound2, theSound2)
end mWriteSound2
-- pass in a list of all the frames to be recorded in and what to be recorded in each.
on mWriteFrame me, frameList
global gkTransparentInk
tell the stage
beginRecording
repeat with theFrameNum = 1 to count(frameList)
set theFrameStuff = getAt(frameList, theFrameNum)
-- put theFrameStuff
go to frame getAt(theFrameStuff, 1)
-- frame properties
repeat with theChannel = 2 to count(theFrameStuff)
set theChannelList = getAt(theFrameStuff, theChannel)
set theChannelType = getAt(theChannelList, 1)
case theChannelType of
#label : set the frameLabel = getAt(theChannelList, 2)
#tempo : set the frameTempo = getAt(theChannelList, 2)
#palette : set the framePalette = getAt(theChannelList, 2)
#transition :
set theTransition = getAt(theChannelList, 2)
set transitionMember = new(#transition)
if theTransition = "wipe down" then
set the transitiontype of transitionMember = 3
set the chunkSize of transitionMember = 2
else if theTransition = "dissolve, pixels fast" then
set the transitiontype of transitionMember = 23
set the chunkSize of transitionMember = 1
end if
set the duration of transitionMember = 2000
set the frameTransition = transitionMember
#sound1 : set the frameSound1 = getAt(theChannelList, 2)
#sound2 : set the frameSound2 = getAt(theChannelList, 2)
#sprite :
set theSpriteNum = getAt(theChannelList, 2)
set the castNum of sprite theSpriteNum = getAt(theChannelList, 3)
set the foreColor of sprite theSpriteNum = getAt(theChannelList, 4)
set the backColor of sprite theSpriteNum = getAt(theChannelList, 5)
set the locH of sprite theSpriteNum =getAt(theChannelList, 6)
set the locV of sprite theSpriteNum = getAt(theChannelList, 7)
set the ink of sprite theSpriteNum = gkTransparentInk
set the tweened of sprite theSpriteNum to 1
set w = getAt(theChannelList, 8)
set h = getAt(theChannelList, 9)
-- last two are primarily to support Zoom effect
if w <> 0 then
set the width of sprite theSpriteNum = w
end if
if h <> 0 then
set the height of sprite theSpriteNum = h
end if
end case
end repeat -- theChannel
updateFrame
end repeat -- theFrameNum
endRecording
end tell
end mWriteFrame
--gets rid of the extra tempo setting, if we set it.
on mClean me
if iNeedClean = true then
tell the stage
set iLastFrame = the lastFrame
beginRecording
go to frame iLastFrame
set the frameTempo to 0
endrecording
end tell
end if
end mClean